<?php

namespace backend\modules\orders\models;

use Yii;

/**
 * This is the model class for table "share_reb_user".
 *
 * @property string $share_reb_user_id
 * @property string $user_id
 * @property integer $reb_number
 * @property integer $reb_used_number
 * @property integer $created_at
 */
class ShareRebUser extends \yii\db\ActiveRecord
{
    /**
     * @inheritdoc
     */
    public static function tableName()
    {
        return 'share_reb_user';
    }

    /**
     * @inheritdoc
     */
    public function behaviors()
    {
        return [
//            TimestampBehavior::className(),
            // 名为myBehavior4的行为，也是给出了MyBehavior类的配置数组
            'uuid' => [
                'class' => \common\behavior\uuidBehavior::className(),
                'owner' => $this
            ]
        ];
    }

    /**
     * @inheritdoc
     */
    public function rules()
    {
        return [
            ['share_reb_user_id','default','value'=>$this->getUUID()],
            ['created_at','default','value'=>time()],
            ['reb_used_number','default','value'=>0],
            [['share_reb_user_id', 'user_id', 'created_at'], 'required'],
            [['reb_number', 'reb_used_number', 'created_at'], 'integer'],
            [['share_reb_user_id', 'user_id'], 'string', 'max' => 40],
        ];
    }

    /**
     * @inheritdoc
     */
    public function attributeLabels()
    {
        return [
            'share_reb_user_id' => Yii::t('app', 'Share Reb User ID'),
            'user_id' => Yii::t('app', 'User ID'),
            'reb_number' => Yii::t('app', 'Reb Number'),
            'reb_used_number' => Yii::t('app', 'Reb Used Number'),
            'created_at' => Yii::t('app', 'Created At'),
        ];
    }

    /**
     * @inheritdoc
     * @return \backend\modules\orders\models\query\ShareRebUserQuery the active query used by this AR class.
     */
    public static function find()
    {
        return new \backend\modules\orders\models\query\ShareRebUserQuery(get_called_class());
    }
}
